import { QXEvent } from "qx-util";
import { IParam, PortletActionType, IPortletAbility, IPortletControllerParams, IPortletStore, PortletController, ICtrlEvent, IPortletController, IPortletModel } from "@/core";
import { usePortletAction, usePortletBasic, usePortletControllerParams, usePortletProps } from "@/hooks/widget/use-portlet";
import { model } from "./dashboard-viewdashboard-container-5-portal-components-list-4-portlet-model";
// 基于template/src/widgets/{{appEntities}}/{{spinalCase ctrl.parent.codeName}}-{{ctrls@PORTLET}}-portlet/{{spinalCase ctrl.parent.codeName}}-{{spinalCase ctrl.codeName}}-portlet-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...usePortletProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...usePortletBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...usePortletAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<PortletActionType, IPortletAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<PortletActionType, IPortletAbility>>,
    otherParams: IParam = {},
): IPortletController<IPortletStore, IPortletAbility> {
	const params: IPortletControllerParams<PortletActionType, IPortletAbility> =
		usePortletControllerParams<IPortletStore, IPortletModel>(model, props, evt, otherParams);
  	return new PortletController(params);
}